package homework4

import (
	"fmt"
	"io"
	"os"
)

func Level02() {
	file, err := os.Create("./plan.txt")
	if err != nil {
		return
	}
	_, err2 := file.Write([]byte("I’m not afraid of difficulties and insist on learning programming"))
	if err2 != nil {
		return
	}

	file, _ = os.Open("./plan.txt")
	r := make([]byte, 100) // 简单读取
	read, err3 := file.Read(r)
	if err3 != nil {
		if err3 == io.EOF {
			fmt.Println(err3)
		}
		return
	}
	fmt.Println(string(r[:read]))
}
